using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class RequestServerVariablesPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    
        //ViewServerVariables();
        //GetServerVariables();
        //GetValueOfServerVariables();
        GetValueOfServerVariable();
    }
    void ViewServerVariables()
    {
        Literal1.Text = "Parameters of ServerVariables<br>";
        foreach (string key in Request.ServerVariables.AllKeys)
        {
            Literal1.Text += key + "<br>";
        }
    }

    void GetServerVariables()
    {
        Literal1.Text = "Parameters of ServerVariables<br>";
        for (int i = 0; i < Request.ServerVariables.Count; i++)
        {
            Literal1.Text += Request.ServerVariables.GetKey(i) + "<br>";
        }
    }
    void GetValueOfServerVariables()
    {
        Literal1.Text = "Value of Parameters in ServerVariables<br>";
        foreach (string key in Request.ServerVariables.AllKeys)
        {
            if(Request.ServerVariables.Get(key)!=null)
            {
                Literal1.Text += key + ": ";
                Literal1.Text += Request.ServerVariables.Get(key) + "<br>";
            }
        }
        
    }
    void GetValueOfServerVariable()
    {
        Literal1.Text = "Value of Parameters in ServerVariables<br>";
        Literal1.Text += "URL: ";
        Literal1.Text += Request.ServerVariables.Get("URL") + "<br>";
        Literal1.Text += "HTTP_HOST: ";
        Literal1.Text += Request.ServerVariables.Get("HTTP_HOST") + "<br>";    
    }
}
